import asyncio

l=[]
lock=asyncio.Lock()
async def work(name):
    print('lalalalalalalala')
    async with lock:
        print(f'{name} start')
        if 'x' in l:
            return name
        await asyncio.sleep(0)
        print('----------')
        l.append('x')
        print(f'{name} end')
        return name

async def one():
    name=await work('one')
    print(f'{name} ok')

async def two():
    name=await work('two')
    print(f'{name} ok')

def main():
    loop=asyncio.new_event_loop()
    asyncio.set_event_loop(loop)
    tasks=asyncio.wait([one(),two()])
    loop.run_until_complete(tasks)

main()
